﻿using System;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Collections.Generic;

using Cratos.Desktop;

namespace Cratos.Generator
{
	/// <summary>
	/// Application Presenter class
	/// </summary>
	public class ApplicationPresenter : MVPPresenter<ApplicationShell>
	{
		#region Class Constant declarations
		#endregion

		#region Class Event declarations
		#endregion

		#region Class Variable declarations
		private string m_StatusText	= "Ready";
		#endregion

		#region Class Constructors & Destructors
		/// <summary>
		/// Class Constructor
		/// </summary>
		public ApplicationPresenter(ApplicationShell appView) : base(appView)
		{
			// Perform the relevant Window Setup
			this.WindowSetup();
		}
		#endregion

		#region Class Properties
		/// <summary>
		/// Status Text
		/// </summary>
		public string StatusText
		{
			get { return (this.m_StatusText); }
			set { this.m_StatusText = value; this.OnNotifyPropertyChanged("StatusText"); }
		}

		/// <summary>
		/// Application Version
		/// </summary>
		public static string Version
		{
			get { return (CratosHelper.AssemblyVersion); }
		}

		/// <summary>
		/// Visibility indicator
		/// </summary>
		public Visibility IsVisible
		{
			get { return (Visibility.Visible); }
		}
		#endregion

		#region Class Methods
		/// <summary>
		/// Close a Tab
		/// </summary>
		/// <typeparam name="T">View</typeparam>
		/// <param name="currentPresenter">Presenter</param>
		public void CloseTab<T>(MVPPresenter<T> currentPresenter)
		{
			// Declare the required variables

			// Remove the Tab from the current View
			this.View.RemoveTab(currentPresenter);

			// Return to calling method
			return;
		}

		/// <summary>
		/// New Project window
		/// </summary>
		public void NewProject()
		{
			// Declare the required variables

			// Remove the Tab from the current View
			this.View.AddTab(new ProjectPresenter(this, new ProjectView()));

			// Return to calling method
			return;
		}

		/// <summary>
		/// Open an existing Project window
		/// </summary>
		public void OpenProject()
		{
			// Declare the required variables

			// Remove the Tab from the current View
			this.View.AddTab(new OpenProjectPresenter(this, new OpenProjectView()));

			// Return to calling method
			return;
		}

		/// <summary>
		/// Open an existing Project window
		/// </summary>
		public void OpenProject(long projectID)
		{
			// Declare the required variables
			ProjectPresenter projectPresenter;

			// Create and Setup the Presenter
			projectPresenter = new ProjectPresenter(this, new ProjectView());
			projectPresenter.LoadProject(projectID);

			// Add a new Tab 
			this.View.AddTab(projectPresenter);

			// Return to calling method
			return;
		}

		/// <summary>
		/// Perform the Window Setup
		/// </summary>
		public void WindowSetup()
		{
			// Declare the required variables

			// Return to calling method
			return;
		}

		/// <summary>
		/// Can Execute Function
		/// </summary>
		/// <param name="originalSource">Original Source</param>
		/// <returns>A boolean value indicating whether the function can be executed or not</returns>
		public bool CanExecuteFunction(object originalSource)
		{
			// Declare the required variables
			bool returnValue = false;

			// Return to calling method
			return (returnValue);
		}
		#endregion

		#region Class Support Methods
		#endregion
	}
}
